package com.zxcl.controller;

import com.zxcl.dto.PhoneDTO;
import com.zxcl.model.Result;
import com.zxcl.service.MemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述: [发送管理接口]
 * 作者: zxcl
 */
@RestController
@Api(tags = "发送管理接口")
@RequestMapping("p/sms")
public class SendController {

    @Autowired
    private MemberService memberService;

    @PostMapping("send")
    @ApiOperation("发送验证码")
    public Result<String> sendPhoneCode(@RequestBody PhoneDTO phoneDTO) {
        memberService.sendPhoneCode(phoneDTO);
        return Result.success("发送成功，请稍后在手机查看");
    }


    @PostMapping("savePhone")
    @ApiOperation("保存手机号码")
    public Result<String> savePhone(@RequestBody PhoneDTO phoneDTO) {
        Integer i = memberService.savePhone(phoneDTO);
        return Result.handle(i > 0);
    }

}
